# 1. 需要一个空列表
list1 = []
list2 = list()

# 2. 数据类型没有限制,允许重复,是有序的
list3 = [1,"11",2,1,"11",True,["111","tom"]]

print(list3[len(list3)-1]) # ['111', 'tom']

# 3. 缩印可以从尾部开始,最后一个元素的索引为-1 -2 -3

list4 = [1,2,3,4,5,6]
print(list4[-2]) # 5


# 4. 通过赋值对数据进行更新

list5 = [1,2,3,4,5,6]

print(list5) #[1, 2, 3, 4, 5, 6]
list5[0] = 333

print(list5) # [333, 2, 3, 4, 5, 6]


# 5.追加

list6 = [111,222,333] # [111, 222, 333]
print(list6)

list6.append(22233) #[111, 222, 333, 22233]
print(list6)


# 6.删除

list7 = [11,22,33,44]
print(list7)
# [11, 22, 33, 44]

del list7[3]
print(list7)
# [11, 22, 33]

# 7. 列表的元素是可以修改的, 修改后,列表变量指向的地址不变,这是数据发生变化
list8 = [11,22,33,44]
print(f"list8 = {list8}, id = {id(list8)}, l8_1_id = {id(list8[1])}") #list8 = [11, 22, 33, 44], id = 2552173436416, l8_1_id = 140731709785672
list8[1] = 55
print(f"list8 = {list8}, id = {id(list8)}, l8_1_id = {id(list8[1])}") #list8 = [11, 55, 33, 44], id = 2552173436416, l8_1_id = 140731709786728

list9 = [111,222,333]
list10 = list9

list10.append(444)
print(list9) # [111, 222, 333, 444]

def f1(l1):
    print(l1) #[111, 222]
    l1.append(222)

list11 = [111,222]
print(list11) # [111, 222]
f1(list11)
print(list11) # [111, 222, 222]

